#ifndef  PWM_H
#define  PWM_H


#include <stdio.h>
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>

#define PWM_CHIP 0
#define PWM_CHANNEL 0
#define PWM_PATH "/sys/class/pwm/pwmchip%d/pwm%d/"
#define PWM_PATH_PORT "/sys/class/pwm/pwmchip%d/"
#define PWM_PATH0 "/sys/class/pwm/pwmchip0/pwm0/"
#define PWM_PATH1 "/sys/class/pwm/pwmchip0/pwm1/"
#define PWM_PATH2 "/sys/class/pwm/pwmchip1/pwm2/"
#define PWM_PATH3 "/sys/class/pwm/pwmchip1/pwm3/"
#define PWM_PATH_PORT0 "/sys/class/pwm/pwmchip0/"
#define PWM_PATH_PORT1 "/sys/class/pwm/pwmchip1/"

#define PWM_PATH_EXPORT "/sys/class/pwm/pwmchip%d/export"
#define PWM_PATH_PERIOD "/sys/class/pwm/pwmchip%d/pwm%d/period"
#define PWM_PATH_DUTY_CYCLE "/sys/class/pwm/pwmchip%d/pwm%d/duty_cycle"
#define PWM_PATH_ENABLE "/sys/class/pwm/pwmchip%d/pwm%d/enable"
#define PWM_PATH_POLARITY "/sys/class/pwm/pwmchip%d/pwm%d/polarity"

void write_pwm_file(int chip, int channel, const char *file, const char *value);
void write_pwm_file_port(int chip, int channel, const char *file, const char *value);
void pwm_disable();
void pwm_control(int period, int duty);
void pwm_init(int pwm_chip,int pwm_channel);
void pwm_set(int pwm_chip,int pwm_channel,int duty);
void pwm_set_polarity(int pwm_chip,int pwm_channel,const char *polarity);

#endif